.class public Lcom/vividsolutions/jts/algorithm/CentroidLine;
.super Ljava/lang/Object;
.source "CentroidLine.java"


# instance fields
.field private centSum:Lcom/vividsolutions/jts/geom/Coordinate;

.field private totalLength:D


# direct methods
.method public constructor <init>()V
    .locals 2

    .line 52
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 48
    new-instance v0, Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-direct {v0}, Lcom/vividsolutions/jts/geom/Coordinate;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->centSum:Lcom/vividsolutions/jts/geom/Coordinate;

    const-wide/16 v0, 0x0

    .line 49
    iput-wide v0, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->totalLength:D

    return-void
.end method


# virtual methods
.method public add(Lcom/vividsolutions/jts/geom/Geometry;)V
    .locals 2

    .line 62
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/LineString;

    if-eqz v0, :cond_0

    .line 63
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Geometry;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    invoke-virtual {p0, p1}, Lcom/vividsolutions/jts/algorithm/CentroidLine;->add([Lcom/vividsolutions/jts/geom/Coordinate;)V

    goto :goto_1

    .line 65
    :cond_0
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/GeometryCollection;

    if-eqz v0, :cond_1

    .line 66
    check-cast p1, Lcom/vividsolutions/jts/geom/GeometryCollection;

    const/4 v0, 0x0

    .line 67
    :goto_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getNumGeometries()I

    move-result v1

    if-ge v0, v1, :cond_1

    .line 68
    invoke-virtual {p1, v0}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getGeometryN(I)Lcom/vividsolutions/jts/geom/Geometry;

    move-result-object v1

    invoke-virtual {p0, v1}, Lcom/vividsolutions/jts/algorithm/CentroidLine;->add(Lcom/vividsolutions/jts/geom/Geometry;)V

    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    :cond_1
    :goto_1
    return-void
.end method

.method public add([Lcom/vividsolutions/jts/geom/Coordinate;)V
    .locals 11

    const/4 v0, 0x0

    .line 87
    :goto_0
    array-length v1, p1

    add-int/lit8 v1, v1, -0x1

    if-ge v0, v1, :cond_0

    .line 88
    aget-object v1, p1, v0

    add-int/lit8 v2, v0, 0x1

    aget-object v3, p1, v2

    invoke-virtual {v1, v3}, Lcom/vividsolutions/jts/geom/Coordinate;->distance(Lcom/vividsolutions/jts/geom/Coordinate;)D

    move-result-wide v3

    .line 89
    iget-wide v5, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->totalLength:D

    add-double/2addr v5, v3

    iput-wide v5, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->totalLength:D

    .line 91
    aget-object v1, p1, v0

    iget-wide v5, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    aget-object v1, p1, v2

    iget-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    add-double/2addr v5, v7

    const-wide/high16 v7, 0x4000000000000000L    # 2.0

    div-double/2addr v5, v7

    .line 92
    iget-object v1, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->centSum:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v9, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    mul-double v5, v5, v3

    add-double/2addr v9, v5

    iput-wide v9, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 93
    aget-object v0, p1, v0

    iget-wide v5, v0, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    aget-object v0, p1, v2

    iget-wide v9, v0, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    add-double/2addr v5, v9

    div-double/2addr v5, v7

    .line 94
    iget-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    mul-double v3, v3, v5

    add-double/2addr v7, v3

    iput-wide v7, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    move v0, v2

    goto :goto_0

    :cond_0
    return-void
.end method

.method public getCentroid()Lcom/vividsolutions/jts/geom/Coordinate;
    .locals 6

    .line 75
    new-instance v0, Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-direct {v0}, Lcom/vividsolutions/jts/geom/Coordinate;-><init>()V

    .line 76
    iget-object v1, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->centSum:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-wide v2, v1, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    iget-wide v4, p0, Lcom/vividsolutions/jts/algorithm/CentroidLine;->totalLength:D

    div-double/2addr v2, v4

    iput-wide v2, v0, Lcom/vividsolutions/jts/geom/Coordinate;->x:D

    .line 77
    iget-wide v1, v1, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    div-double/2addr v1, v4

    iput-wide v1, v0, Lcom/vividsolutions/jts/geom/Coordinate;->y:D

    return-object v0
.end method
